package com.web.base.user.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.blue.jdbc.JdbcDataSource;
import com.blue.jdbc.Page;
import com.web.base.user.dao.OfficeDao;
import com.web.base.user.model.Office;
import com.web.core.util.Const;

/**
 * 部门业务层
 * 
 * @author 代码由 blue-code 框架生成
 * @since 1.0 2017年04月16日
 */
@Service
@Transactional
@JdbcDataSource(Const.DS_BASE)
public class OfficeService
{
	@Resource
	private OfficeDao officeDao;
	
	public OfficeService()
	{
	}
	
	public Office save(Office office)
	{
		if (office.getId() == null)
		{
			officeDao.save(office);
		}
		else
		{
			officeDao.update(office);
		}
		Office a = officeDao.get(office.getId());
		return a;
	}
	
	public Office get(Integer id)
	{
		Office log = officeDao.get(id);
		return log;
	}
	
	public Page<Office> list(Office office, Page<Office> page)
	{
		page = officeDao.list(office, page);
		return page;
	}
	
	public List<Office> list(Office office)
	{
		List<Office> list = officeDao.list(office);
		return list;
	}
	
	public void delete(Office office)
	{
		officeDao.delete(office);
	}
	
}
